<script>
import i18n from '@/locale'

export default {
  name: 'DynTextarea',
  model: {
    prop: 'value',
    event: 'input'
  },
  props: {
    value: {
      type: [String, Number], // 验证类型后续可以增加
      default: ''
    },
    item: {
      type: Object,
      default: () => ({})
    }
  },
  methods: {
    handlerInput(value) {
      this.$emit('input', value)
      this.item.event && this.item.event(value)
    }
  },
  render: function(h) {
    return (
      <el-input
        style={this.style}
        value={this.value}
        disabled={this.item.disabled}
        on-input={this.handlerInput.bind(this)}
        placeholder={`${i18n.t('pleaseInput')}${this.item.label}`}
        rows={this.item.row ? this.item.row : 2}
        show-word-limit={this.item.show_word_limit || false}
        maxlength={this.item.maxlength || undefined}
        type='textarea'/>
    )
  }
}
</script>

